|
|
|
|
|
|
|
When to Use the Snapshot Data Object |
|
|
|
|
|
|
|
|
Visual Basic Snapshot-type Recordset objects work best if you have a small set of data that you need to access frequently. For example, if you have a list of valid input values for a particular field stored in a control table, you can load these valid values into a Snapshot and refer to that dataset each time you need to verify user input. |
|
|
|
|
|
|
|
|
If the dataset is not too large, Snapshots are very good for use in creating calculated reports or graphic displays. It is usually a good idea to create a static dataset for use in calculating reports. This way, any changes in the dataset that might occur in a multiuser environment from the time you start the report to the time you end it will not confuse any calculations done by the report. |
|
|
|
|
| |
|
|
|
|
It's a good idea to keep your Snapshots to less then 64KB in size. You can estimate the eventual size of your Snapshots by calculating the number of bytes in an average data record and estimating the average number of records you can expect in your Snapshot. You can refer to Day 2, ''Creating Databases," for information on the size of Visual Basic data types. |
|
|
|
|
|
|
|
|
|
|
The Database Data Objects |
|
|
|
|
|
|
|
|
The Database object of a Visual Basic data control allows you access to all the properties and methods associated with the database underlying the data control. By using the related data objects, TableDefs, Fields, and Indexes, you can get information about all the tables in the database, all the indexes in the database, and all the fields in each table. Also, you can get additional information about the field types and index parameters. |
|
|
|
|
|
|
|
|
The Database data object is most useful when you are developing generic database routines. Because the Database object gives you access to all the field names and properties, you can use this information to write generic data table display and update routines instead of having to write routines that have hard-coded field names and data types. TableDefs objects are covered in more detail on Day 10, "Creating Database Programs with Visual Basic Code". For now, though, let's write a short routine that lists all the tables, fields, and indexes in the BOOKS5.MDB database. |
|
|
|
|
|
|
|
|
First, start a new Standard EXE project in Visual Basic 5 and load the Microsoft Jet DAO 3.5 Object Library. Use the information in Table 3.3 to set the form property settings and place the data control on the form. |
|
|
|
|
|